<?php
    include_once('../lang.php');
    include('../config.ini.php');
    include('function.php');
    
    $db = db_connect();
    
    $project_id = $_POST['project_id'];
    
    $sql = "SELECT * FROM projects WHERE project_id=$project_id";
    $result = mysql_query($sql);
    
    $house_['project_thumb_list'] = '<ul>';
    
    $row2=mysql_fetch_assoc($result);
    
    if($row2['project_img']!='' && file_exists( "../images/projects/".$row2['project_id']."/big_".$row2['project_img'])){
	$project_img_first = $row2['project_id'].'/big_'.$row2['project_img'];
    }else if($row2['project_img']!='' && file_exists( "../images/projects/".$row2['project_id']."/".$row2['project_img'])){
	$project_img_first = $row2['project_id'].'/'.$row2['project_img'];
    }else{
	$project_img_first = 'no-pic.jpg';
    }
    
    $sql = "SELECT * FROM project_img WHERE project_id=$project_id AND project_img_show=1 ORDER BY img_position";
    $result = mysql_query($sql);
    
    $countRow = mysql_num_rows($result);
    
    if($countRow){
	$i = 1;
	$project_detail_title = $row2['project_title'];
	$house_['project_thumb_list_show_slide'] = 1;
	while($row=mysql_fetch_assoc($result)){
	    if(file_exists('../images/projects/'.$project_id.'/'.$row['project_img_path']) && trim($row['project_img_path'])!=''){
		if($i==1){
		    $house_['project_thumb_list'] .=<<<showcase_lits
			<li id="{$row['project_img_id']}">
			    <img src="images/projects/{$project_id}/{$row['project_img_path']}" alt="{$project_detail_title}" class="project_thumb_gallery thumb_active" />
			</li>
showcase_lits;
		    $project_img_first = $project_id.'/'.$row['project_img_path'];
		}else{
		    $house_['project_thumb_list'] .=<<<showcase_lits
			<li id="{$row['project_img_id']}">
			    <img src="images/projects/{$project_id}/{$row['project_img_path']}" alt="{$project_detail_title}" class="project_thumb_gallery" />
			</li>
showcase_lits;
		}
		
		$i++;
	    }
	}
    }else{
	$house_['project_thumb_list_show_slide'] = 0;
    }
    
    if(file_exists('../images/projects/'.$project_id.'/'.$row['project_cert']) && trim($row2['project_cert'])!=''){
	$house_['project_cert'] = '<a href="images/projects/'.$project_id.'/'.$row2['project_cert'].'" class="certColorBox"><img src="images/cert_bt.png" alt="Certificate"/></a>';
    }else{
	$house_['project_cert'] = '';
    }
    
    $house_['project_thumb_list'] .= '</ul>';

    $house_['project_img'] = 'images/projects/'.$project_img_first;
    $house_['project_r_detail_date'] = date("F j Y",strtotime($row2['project_date'])).' //';
    
    $project_value = number_format($row2['project_value'], 0, '.', ',');
    $house_['project_r_detail_title'] = $row2['project_title'];
    
    $project_area_title = __l('project-area-title');
    $owner_title = __l('project-owner-title');
    $project_complete_title = __l('project-complete-title');
    $project_value_title = __l('project-value-title');
    
    if($row2['project_area']>0){
	$project_area  = $row2['project_area'];
	$projectarea = __l('project-area');
    }else{
	$project_area = __l('no-project-area');
	$projectarea = '';
    }
    
    if(trim($row2['project_owner'])!=''){
	$project_owner  = $row2['project_owner'];
    }else{
	$project_owner  = __l('no-project-owner');
    }
    
    if(trim($row2['project_complete_year'])!=''){
	$project_complete_year  = $row2['project_complete_year'];
    }else{
	$project_complete_year  = __l('no-project-complete-year');
    }
    
    if($row2['project_value']>0){
	$project_value  = number_format($row2['project_value'], 0, '.', ',');
	$projectvalue = __l('project-value');
    }else{
	$project_value = __l('no-project-value');
	$projectvalue = '';
    }
    
    $house_['project_r_detail_'] =<<<showcase_img_lits
	    <span class="span_owner-title">{$project_area_title} : </span>{$project_area} {$projectarea}<br />
	    <span class="span_owner span_owner-title span_owner_{$lang}">{$owner_title} : </span><span class="owner-title owner-title-project-page">{$project_owner}</span>
	    <br />
	    <span class="span_owner-title">{$project_complete_title} : </span>{$project_complete_year}<br />
	    <span class="span_owner-title">{$project_value_title} : </span>{$project_value} {$projectvalue}<br />
showcase_img_lits;
    
    echo json_encode($house_);
    
    db_close($db);
?>